JavaScript

{dialog.object}refreshDropdownBoxChoices Method

Syntax

{dialog.Object}.refreshDropdownBoxChoices(controlName [,dynamicFilter [,dynamicFilterArguments [,selectedValue [,currentRowOnly]]]]);

{dialog.Object}.refreshDropdownBoxChoices(controls);

Arguments

controlNameString

The name of the dropdownBox control.

controlsStringJSON String

A comma-delimited list of controls to refresh or a JSON String specifying the controls to refresh as well as additional properties. The JSON string can specify the following options for each control:

controlNameString

The name of the dropdownBox control.

dynamicFilterString

A dynamic filter to apply when recomputing the choices in the DropdownBox.

dynamicFilterArgumentsString

If a dynamic filter is specified, and the filter uses arguments, this parameter contains the argument values. See dynamicFilterArguments below for a description of the arguments format to use.

selectedValue

The value in the DropdownBox to select after it has been repopulated.

currentRowOnlyBoolean

Default = true. If the control is in a Repeating Section, the choices in all rows in the Repeating Section are updated. If this parameter is false, then only the choices in the Dropbownbox in the current row are updated.

dynamicFilterString

A dynamic filter to apply when recomputing the choices in the DropdownBox.

dynamicFilterArgumentsString

If a dynamic filter is specified, and the filter uses arguments, this parameter contains the argument values. The format for this argument is a CR-LF delimited string in this format: argumentValue|||dataType|argumentName

selectedValue

The value in the DropdownBox to select after it has been repopulated.

currentRowOnlyBoolean

Default = true. If the control is in a Repeating Section, the choices in all rows in the Repeating Section are updated. If this parameter is false, then only the choices in the Dropbownbox in the current row are updated.

Description

Does an Ajax callback to recompute the choices in a DropdownBox and repopulates the choices in the DropbownBox for the specified controlName.

Applies only if the choices in the Dropdownbox are based on a SQL or .dbf query.

Example

Refresh the choices in the DropdownBox for the 'products' control.

{dialog.object}.refreshDropdownBoxChoices('PRODUCTS');

Refresh the choices and set the select to 'PRODUCT_X'

{dialog.object}.refreshDropdownBoxChoices('PRODUCTS','','','PRODUCT_X');

Refresh the choices and filter choices to only show items where the 'type' field is 'a' and 'code' field is 'x'

var controlID = 'PRODUCTS';
var filter = 'type=:whatType and code = :whatCode';
var arguments = 'a|||c|whatType\nx|||c|whatCode';

{dialog.object}.refreshDropdownBoxChoices(controlID, filter, arguments);

Note that in the above example the dynamicFilterArguments is a crlf delimited string (\n is the CRLF code in javascript) of the form

value|||datatype|argumentname

Refreshing Multiple DropdownBoxes in a Single Callback

If you want to refresh multiple Dropdownbox controls, it is much more efficient to make a single Ajax callback that separate callbacks for each Dropdownbox. You can specify a comma delimited list of Drodownbox controls to refresh. For example:

//Refreshing the 'CITY' and 'COUNTRY' Dropdownboxes in a single 
//callback (specify a comma delimited list of controls)

{dialog.object}.refreshDropdownBoxChoices('CITY,COUNTRY');

Specifying the list of dropdownBox controls precludes the option of specifying any of the optional parameters. If optional parameters are needed, then a JSON string can be used to specify the controls to refresh.

The JSON string can be used to specify any optional parameters available for a single control refresh: controlName, dynamicFilter, dynamicFilterArguments, selectedValue, currentRSRowOnly. In the example below, a JSON string is created so a dynamicFilter can be added for each dropdownBox control:

//Refresh 'CITY' and 'COUNTRY' using JSON string syntax
var arr = [];
arr.push({controlName: "country", dynamicFilter: "country = 'usa' or country = 'uk'"});
arr.push({controlName: "city", dynamicFilter: "country = 'usa' or country = 'uk'"});

var json = JSON.stringify(arr);

{dialog.Object}.refreshDropdownBoxChoices(json);

See Also